import uuid
from app.websocket_manager import ManagerDep
from fastapi import APIRouter, WebSocket
from loguru import logger

router = APIRouter(prefix="/web", tags=["web"])

@router.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket,manager: ManagerDep):
    await websocket.accept()
    while True:
        try:
            manager.add_web(websocket, uuid.uuid4().hex)
            data = await websocket.receive_json()
            # 处理接收到的数据
        except Exception as e:
            # logger.exception(e)
            break